local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script,script.Parent.Base);
local ConnectClass=_G.CommonOHOH.load.Connect();

-- 钻头
function M.new(...)
	return M(...);
end;

function M.ctor(self,...)--构造函数
	M.super.ctor(self,...);

	--body更新，点位发生变化，自己也得更新
	self.Car.BodyUpdateEvent:Connect(function()
			if self.CarId then
				self:Update(self.CarId)
			end
	end)


end;

function M.dtor(self)
	M.super.dtor(self);
end;
--组装到整车上（子类实现）
function M.Assemble(self)
	self.Body=self.Car:GetBody()

	-- self.Instance = {}
	-- local drill=self.Model.Instance
	self.Instance.Name= "Weapon"

	-- table.insert(self.Instance, drill)

	self.Instance:PivotTo(self.Body:GetWeaponPivot())
	self.Instance.Parent= self.Body:GetInstance()

	local folder = Instance.new("Folder",self.Body:GetInstance())
	folder.Name = "WeaponMesh"

    for _, protect in pairs( self.Instance:GetChildren()) do
    	protect.Parent = folder
		self:Weld2Part(protect,self.Body:GetInstance())
		-- table.insert(self.Instance, protect)
    end

	local att0 = Instance.new("Attachment",self.Body:GetInstance())
	att0.Name = "weapon1"
	att0.WorldPosition = self.Body:GetWeaponPostion()
	att0.WorldOrientation =self.Body:GetWeaponOrientation() + Vector3.new(0,90,0)
	
	local att1 = Instance.new("Attachment",self.Instance)
	att1.Name = "weapon2 "
	att1.WorldPosition =  self.Body:GetWeaponPostion()
	att1.WorldOrientation =self.Body:GetWeaponOrientation() + Vector3.new(0,90,0)
	
	local hin = Instance.new("HingeConstraint",self.Body:GetInstance())
	hin.Name = "weapon"
	hin.Attachment0 = att0
	hin.Attachment1 = att1
	hin.ActuatorType = Enum.ActuatorType.Motor

end

--设置转速
function M.SetDrillingSpeed(self)

end

-- 获取组装到车上的实例（子类实现）
function M.GetInstance(self)
	return self.Instance
end
return M